from crawl4ai import LLMExtractionStrategy
from typing import Optional, Dict

class LLMStrategyFactory:
    """
    LLM策略配置工厂类，支持创建不同场景的提取策略
    """
    @staticmethod
    def create_strategy(
        provider: str,
        api_base: str,
        schema: Dict,
        instruction: str,
        api_token: Optional[str] = None
    ) -> LLMExtractionStrategy:
        """
        创建通用LLM提取策略
        
        Args:
            provider: 模型服务提供商
            api_base: API基础地址
            schema: 数据提取的JSON Schema
            instruction: 给LLM的提取指令
            api_token: 可选的API认证令牌
        """
        return LLMExtractionStrategy(
            provider=provider,
            api_base=api_base,
            api_token=api_token,
            schema=schema,
            extraction_type="schema",
            instruction=instruction,
            input_format="markdown",
            verbose=True
        )